package ;

import scuts.F;

class Main
{
	
	static function main () {
		
   
   
    
    trace(F.ac((c + d) * n, c <= 1...3 && d <= 3...5, n <= 1...3)); 
    
    trace("--------Simple-----------------------------------");
		var l = F.ac(x, x <= 1...10);
		
    trace(l);
    
    trace("-------- Simple guard -----------------------------------");
		
		var l = F.ac(x, x <= 1...10 || x % 2 == 0);
		trace(l);
    
    trace("-------- Names and ages (nested and lazy)-----------------------------------");
		
    var names = ["jimmy", "peter", "frank", "joy"];
		var ages = [88, 37, 19, 25];
		
		var myIter2 = F.lazy( {name:n, age:a}, n <= names && a <= ages );

		for (i in myIter2) trace(i);
		
		trace("-------- Articles and Tags (Nested Iterators) -----------------------------------");
		
		var articles = [ { id : 1, tags:["sports", "politics"] }, { id:2, tags:["fun", "economy"] } ];
		
		var allTags = F.ac(t, t <= a.tags, a <= articles);
		trace(allTags);
		
    trace("-------- More Nesting -----------------------------------");
		
		var allTags = F.ac({x:x, y:y, z:z}, x <= 0...3, y <= 0...3, z <= 0...3);
		trace(allTags);
    
		trace("--------Iterator Factories-----------------------------------");
    
    var f = function () {
      var i = 0;
      return {
        hasNext : function () return i < 10,
        next : function () return i++
      }
    }
    
		var l = F.ac(x, x <= f());
		trace(l);
		

		trace("--------Nested Comprehensions-----------------------------------");
		var a = [1, 2, 3];
		var l = F.ac(x+1, x <= F.ac(y+1, y <= 0...4));
		trace(l);
	
		
				
		
		trace("--------List Comprehension-----------------------------------");
		
		var l = F.lc( x > 5 ? "bigger5" : "smaller5", x <= 0...10 || x != 5 && x != 6);
		trace(l);
		
	
    trace("--------Over 18 Example-----------------------------------");
		
		var users = [];
		users.push( { name:"Jim", age:17 } );
		users.push( { name:"Peter", age:18 } );
		users.push( { name:"Walter", age:25 } );
		users.push( { name:"Frank", age:26 } );
		
		var under18 = F.lc( {
				title: "Hello " + x.name + " welcome to this page",
				desc: x.name + " is " + x.age + " years old"
			}, x <= users || x.age >= 18);
		trace(under18);
		
		
		var words = ['The', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'];
		var stuff = F.ac( [w.toUpperCase(), w.toLowerCase(), w.length], w <= words || w.length == 3 );
		
		
    var numbers = [1, 2, 3, 4, 5, 6, 7, 8];
    
    trace(F.ac([c, n], c <= numbers || c * n == 4, n <= numbers)); 
		
	var exprs = [1, 2, 3, 4];
	var mapped = F.ac( { name:"id" + Std.string(i), expr:e }, e <= exprs && i <= 0...exprs.length);
	
	}
		
	
	
}
